{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "random-trail",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/n-repeated-element-in-size-2n-array\n",
    "\n",
    "Runtime: 76 ms, faster than 25.21% of C++ online submissions for N-Repeated Element in Size 2N Array.\n",
    "Memory Usage: 31.5 MB, less than 7.87% of C++ online submissions for N-Repeated Element in Size 2N Array.\n",
    "\n",
    "```cpp\n",
    "#include <vector>\n",
    "#include <algorithm>\n",
    "#include <map>\n",
    "\n",
    "\n",
    "using namespace std;\n",
    "\n",
    "class Solution {\n",
    "public:\n",
    "    int repeatedNTimes(vector<int>& A) {\n",
    "        //8:35\n",
    "        map<int, int> m;\n",
    "        for (int i : A) {\n",
    "            if (m.count(i) > 0) {\n",
    "                m[i] += 1; \n",
    "            } else {\n",
    "                m.insert(pair<int,int>(i, 1));\n",
    "            }\n",
    "        }\n",
    "        int N = A.size()/2;\n",
    "        int target;\n",
    "        for (auto &i : m) {\n",
    "            if (i.second == N) {\n",
    "                target = i.first;\n",
    "                break; // to stop searching\n",
    "            }\n",
    "        }\n",
    "        return target;\n",
    "        //8:47\n",
    "    }\n",
    "};\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cooperative-malawi",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C++17",
   "language": "C++17",
   "name": "xcpp17"
  },
  "language_info": {
   "codemirror_mode": "text/x-c++src",
   "file_extension": ".cpp",
   "mimetype": "text/x-c++src",
   "name": "c++",
   "version": "17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
